package com.webas.components;

import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.annotations.Parameter;

public class Slot {

    @Inject
    private ComponentResources resources;
    
    @Parameter(name = "id", defaultPrefix = BindingConstants.LITERAL, required = true)
    private String id;

    Object beginRender() {
        ComponentResources res = resources.getContainerResources();
        Block toRender = null;
        while (res != null) {
            Block temp = res.findBlock(id);
            if (temp != null) {
                toRender = temp;
            }
            res = res.getContainerResources();
        }
        return toRender;
    }
}